#include <stdio.h>
#include <magic.h>
#include <string.h>



int file_mime(char * path, char * mime_swap)
{
    struct magic_set * ms = NULL;
    ms = magic_open(MAGIC_MIME);
    if (magic_load(ms, NULL) == -1) {
        puts("文件类型检测失败");
        return -1;
    }
    strcpy(mime_swap, magic_file(ms, path));
    return 0;
}

int main(void)
{
    char a[40];
    char b[170];
    char c[] = "HTTP/1.0 200 OK\r\nContent-Type: ";
    file_mime("/home/shrike/template/favicon.ico", a);
    strcpy(b, strcat(c, a));
    puts(b);
    return 0;
}